package com.lin.controller;

import com.lin.entity.Product;
import com.lin.service.ProductService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.beans.factory.annotation.Value;
import org.springframework.cloud.context.config.annotation.RefreshScope;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RequestMethod;
import org.springframework.web.bind.annotation.RestController;

@RestController
@RequestMapping("/product")
@RefreshScope //开启自动刷新，哪个类中要用到就在类上配置
public class ProductController {
    @Value("${name}")
    private String name;
    @Autowired
    private ProductService productService;
    @RequestMapping("/test")
    public String test(){
       return name;
    }
    @RequestMapping(value = "/{id}",method = RequestMethod.GET)
    public Product findById(@PathVariable Long id) {
        return productService.findById(id);
    }

}

